package cn.xiaopengstack.domain.activity.model.entity;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;
import java.util.Date;

/**
 * 抽奖活动用户账户实体
 * @author jiangyangang
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
@Builder
public class RaffleActivityAccountEntity implements Serializable {

    /**
     * 用户ID
     */
    private String userId;

    /**
     * 活动ID
     */
    private Long activityId;

    /**
     * 总次数
     */
    private Integer totalCount;

    /**
     * 总次数-剩余
     */
    private Integer totalCountSurplus;

    /**
     * 日次数
     */
    private Integer dayCount;

    /**
     * 日次数-剩余
     */
    private Integer dayCountSurplus;

    /**
     * 月次数
     */
    private Integer monthCount;

    /**
     * 月次数-剩余
     */
    private Integer monthCountSurplus;

    /**
     * 创建时间
     */
    private Date createTime;

    /**
     * 更新时间
     */
    private Date updateTime;

    private static final long serialVersionUID = 1L;

    /**
     * 初始化一个空的账户
     * @param activityId
     * @param userId
     * @return
     */
    public static RaffleActivityAccountEntity initZeroAccount(Long activityId, String userId) {
        return RaffleActivityAccountEntity.builder()
                .activityId(activityId)
                .userId(userId)
                .dayCount(0)
                .dayCountSurplus(0)
                .monthCount(0)
                .monthCountSurplus(0)
                .totalCount(0)
                .totalCountSurplus(0)
                .build();
    }
}